<?php
/**
 *    part view: friends_list
 *    File: friends/part/friends_list.php
 */
        // FRIEND REQUESTS
        if( count($friend_requests)>0 )
        {
          foreach ($friend_requests as $row)
          {
            if( $row->image_name != NULL )            
              $image = "<img src='".base_url()."profile/image/thumb/{$row->user_id}/{$row->image_name}' alt='{$row->username}'>";            
            else
              $image = "<img src='".base_url()."img/no_photo.gif' alt=''>";
            $name = ( $row->name != "" )?$row->name:$row->username;
            if( $row->accept == 1 ) // Vec je prihvacen za prijetelja 
            {
              $class_new = "";
              $button = "<a href='javascript: remove_friend({$row->user_id})' class='delete-friend confirmLink' name='' title='".lang('remove_friend')."' alt='".lang('confirm_delete_friend')."'  ></a>";//type='button' value=''
            }
            else if ( $row->user_id == $this->session->userdata('user_id') ) { // Ja sam poslao zahtev 
              $class_new = "new";
              $button = "";
            }
            else //poslao je zahtev ali jos nije prihvacen. Preko ovog linka prihvata ga za priojatelja
            {
              $class_new = "new";
              $button = "<a href='javascript: add_friend({$row->id})' class='add-friend confirmLink' name='' title='".lang('add_to_friend')."' alt='".lang('confirm_friend_request')."' ></a>";
            }
            
            echo "
              
              <div class='notifications {$class_new}'>
              {$button}
              <a href='".base_url()."profile/view-profile/{$row->username}.htm'>{$image}<span class='name'>{$name}</span>
              <span class='msg-intro'>{$row->flirt_text}</span>
              </a>
              <div class='clr'></div>
              </div><!--End notifications req-->

                ";
          }
        }
        
        // FRIENDS
        if( count($friends)>0 )
        {
          foreach ($friends as $row)
          {
            if( $row->image_name != NULL )            
              $image = "<img src='".base_url()."profile/image/thumb/{$row->friend_id}/{$row->image_name}' alt='{$row->username}'>";            
            else
              $image = "<img src='".base_url()."img/no_photo.gif' alt=''>";
            $name = ( $row->name != "" )?$row->name:$row->username;
            if( $row->accept == 1 ) // Vec je prihvacen za prijetelja 
            {
              $class_new = "";
              $button = "<a href='javascript: remove_friend({$row->friend_id})' class='delete-friend confirmLink' name='' title='".lang('remove_friend')."' alt='".lang('confirm_delete_friend')."'  ></a>";//type='button' value=''
            }
//            else if ( $row->user_id == $this->session->userdata('user_id') ) { // Ja sam poslao zahtev 
//              $class_new = "new";
//              $button = "";
//            }
            else //poslao je zahtev ali jos nije prihvacen. Preko ovog linka prihvata ga za priojatelja
            {
              $class_new = "new";
              $button = "<a href='javascript: add_friend({$row->id})' class='add-friend confirmLink' name='' title='".lang('add_to_friend')."' alt='".lang('confirm_friend_request')."' ></a>";
            }
            
            echo "
              
              <div class='notifications {$class_new}'>
              {$button}
              <a href='".base_url()."profile/view-profile/{$row->username}.htm'>{$image}<span class='name'>{$name}</span>
              <span class='msg-intro'>{$row->flirt_text}</span>
              </a>
              <div class='clr'></div>
              </div><!--End notifications-->

                ";
          }
        }
 ?>
     <div class="clr"></div>               
            <p id="contentspaginate" class="paginationstyle pagination" align="center">
                        Página: <a href="#" rel="previous" class="imglinks"><<  </a> &nbsp; <span class="flatview"></span> &nbsp; <a href="#" rel="next"> >></a>
       </p>
       <script language='javascript' >
          var contents_home=new virtualpaginate({
              piececlass: "notifications",
              piececontainer: 'div', 
              pieces_per_page: 10,
              defaultpage: 0,
              wraparound: false,
              persist: false
          })

          contents_home.buildpagination(["contentspaginate"]);
        </script>
        <script src="<?php echo base_url(); ?>js/dialog.js"></script>